<%@ page language="java" contentType="text/html;charset=UTF-8" %><%@ include file="../../inc/global.jsp" 
%><compress:html enabled="true" removeComments="false" compressJavaScript="true" yuiJsDisableOptimizations="true">
<!doctype html>
<html>
<head>
<title>${adminGlobalConfig.name}</title>
<%@include file="../head.jsp" %>
<style type="text/css">
#goodsList table tr, #goodsList table td {
	height:22px;
}
.sellItem { margin-left:7px;}
</style>
<script type="text/javascript"> 
$(function(){
	var slt = new selector();
	slt.init();
	slt.choice($('#villageId').val());
	//
	$("#name").autocomplete("/a/ajax/search/customer",{
		delay: 500
		, formatItem:function(item, index, total, query){
	    	return item.townName + " " + item.villageName + " " + item.customerName;
	    }
		, formatResult:function(item){
	    	return item.customerName;
	    }
		, dataType:'json'
		, parse:function(data) {
             return $.map(data, function(item) {
                     return {
                             data: item,
                             value: item.customerName,
                             result: item.customerName
                     }
        	}); // end map
		} // end parse

	}).result(function(event, data, formatted) {
		$("#villageId").val(data.villageId);
		$(".choiceVillage a").html(data.townName + " " + data.villageName);
		$("#tel").val(data.tel);
		$("#mobile").val(data.mobile);
	}); // end result
	doSubmit();
}); // end document ready
function doSubmit() {
	$('form').submit(function(){
		$("#submit").attr('disabled', 'disabled');
	});
}
</script> 
</head>
<body>
<div class="wrapper">
<%@include file="../header.jsp" %>
<div class="body">
<div class="form">
<form:form action="/a/customer/save" method="POST" commandName="form">
<form:hidden path="id"/>
<table>
<tr>
<th>顾客</th>
<td>
<form:input path="name"/>
<form:errors cssClass="error" path="name" />
</td>
</tr>
<tr>
<th>村庄</th>
<td>
<div class="selector">
<c:if test="${empty village}">
<a href="###" onclick="village.show();" id="villageSelector">选择村庄</a>
</c:if>
<c:if test="${!empty village}">
<a href="###" onclick="village.show();" id="villageSelector">${village.name}</a>
</c:if>
<input type="hidden" id="villageId" name="villageId" value="${villageId}"/>
</div>
</td>
</tr>
<tr>
<th>移动电话</th>
<td><form:input path="mobile"/></td>
</tr>
<tr>
<th>固定电话</th>
<td><form:input path="tel"/></td>
</tr>
<tr>
<th>备注信息</th>
<td>
<form:textarea path="memo" style="width:280px; height:100px;"/>
</td>
</tr>
<tr>
<th></th>
<td><input type="submit" id="submit" name="submit" value="确定保存" /></td>
</tr>
<c:if test="${CUSTOMER_BALANCE_MODIFY }">
<tr>
<th>个人存款</th>
<td>
<form:input path="balance"/>
</td>
</tr>
</c:if>
<c:if test="${CUSTOMER_DEBT_MODIFY }">
<tr>
<th>个人债务</th>
<td><form:input path="debt"/></td>
</tr>
</c:if>
</table>
</form:form>
</div>
<!--  -->
</div>
</div>
</body>
</html>
</compress:html>